import { Card } from 'antd'
import 'moment/locale/zh-cn'
import { observer } from 'mobx-react-lite'
import { useLocation } from 'react-router-dom'
import SimpleTable from '@/components/SimpleTable'
import StudentExam from '@/pages/Table/MyExam'
import Search from '@/components/Search'
import { useState } from 'react'
import { searchs } from '@/static/search';


const SimpleTableLayout = () => {
  const { pathname } = useLocation()
  const path = pathname.split("/")
  const api = path[path.length - 1]

  const searchForm = searchs[api] ? searchs[api] : []
  const [requetParams, setRequestParams] = useState()

  if(api === "student_exam"){
    return (
      <div>
        <Card>
            <StudentExam api={api} requetParams={requetParams}/>
        </Card>
      </div>
    )
  }else{
    return (
      <div>
        {searchForm && searchForm.length > 0 && (
        <Card style={{ marginBottom: 20 }} >
          <Search api={api} setRequestParams={setRequestParams}/>
        </Card>
        )}
        <Card>
            <SimpleTable api={api} requetParams={requetParams}/>
        </Card>
      </div>
    )
  }
}

export default observer(SimpleTableLayout)